package com.foreknow.springboot_demo.threaddemo;

/**
 * sleep
 */
public class SleepDemo {
    public static void main(String[] args) {
        new Thread("线程1"){
            @Override
            public void run() {
                for (int i=0; i<10;i++){
                    //线程休眠
                    try{
                        Thread.sleep(500);
                    }catch (InterruptedException e){
                        e.printStackTrace();
                    }
                    System.out.println(getName()+"执行了！");
                }
            }
        }.start();


        new Thread("线程2"){
            @Override
            public void run() {
                for (int i=0; i<10;i++){
                    //线程休眠
                    try{
                        Thread.sleep(800);
                    }catch (InterruptedException e){
                        e.printStackTrace();
                    }
                    System.out.println(getName()+"执行了！");
                }
            }
        }.start();

    }
}
